package com.yonyou.cyxdms.basedata.service.controller.color;

import com.yonyou.cyx.framework.controller.base.BaseController;
import com.yonyou.cyxdms.basedata.client.domains.vo.ColorCacheCMSVO;
import com.yonyou.cyxdms.basedata.client.domains.vo.ColorCacheVO;
import com.yonyou.cyxdms.basedata.client.domains.vo.ColorVO;
import com.yonyou.cyxdms.basedata.service.dto.CarInfoDTO;
import com.yonyou.cyxdms.basedata.service.service.color.ColorService;
import com.yonyou.cyxdms.basedata.service.vo.CarInfoVO;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 *  颜色
 *
 * @author: guorp
 * @since: 2018/12/13
 * @updateDate:
 * @updateRemark:
 * @version:1.0 Copyright: Copyright (c) 2018
 */
@RestController
@RequestMapping("/color")
public class ColorController extends BaseController {


    @Autowired
    ColorService colorService;

    /**
     * 根据packageId查询颜色
     *
     * @param packageId
     * @return java.util.List<com.yonyou.cyxdms.basedata.client.domains.DTO.basedata.CarColorDTO>
     * @author guorp
     * @since 2018/12/14
     */
    @GetMapping(value = "/getColorByPackageId")
    public List<ColorVO> getColorByPackageId(@RequestParam Long packageId){
        return colorService.getColorByPackageId(packageId);
    }
    
    /**
     * 根据optionId查询颜色
     *
     * @param optionId
     * @return java.util.List<com.yonyou.cyxdms.basedata.client.domains.DTO.basedata.CarColorDTO>
     * @author zys
     * @since 2020/2/10
     */
    @GetMapping(value = "/getColorByOptionId")
    public List<ColorVO> getColorByPackageIdV2(@RequestParam Long optionId){
        return colorService.getColorByPackageIdV2(optionId);
    }

    /**
     * 按条件查询颜色信息
     *
     * @param queryParam
     * @return java.util.List<com.yonyou.cyxdms.basedata.client.domains.DTO.basedata.ColorCacheVO>
     * @author renwd
     * @since 2018/12/18
     */
    @GetMapping("/queryColorByCondition")
    public List<ColorCacheVO> queryColorByCondition(@RequestParam Map<String, Object> queryParam){
        return colorService.queryColorByCondition(queryParam);
    }

    /**
     * 按条件查询颜色信息
     *
     * @param queryParam
     * @return java.util.List<com.yonyou.cyxdms.basedata.client.domains.DTO.basedata.ColorCacheVO>
     * @author renwd
     * @since 2018/12/18
     */
    @GetMapping("/queryColorByConditionCMS")
    public List<ColorCacheCMSVO> queryColorByConditionCms(@RequestParam Map<String, Object> queryParam){
        return colorService.queryColorByConditionCms(queryParam);
    }

    /**
     * 查询所有颜色
     *
     * @param
     * @return java.util.List<com.yonyou.cyxdms.basedata.client.domains.dto.basedata.CarColorDTO>
     * @author renwd
     * @since 2019/2/28
     */
    @ApiOperation(value = "查询所有颜色")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", required = true, dataType = "string", paramType = "header")
    })
    @GetMapping("/listColor")
    public List<ColorVO> listColor() {
        return colorService.listColor();
    }

    /**
     * 根据车系id或车型id或配置id或颜色id查询车的信息(cyx使用)
     * 此接口仅提供给车营销使用！
     *
     * @param carInfoDTO
     * @return java.util.List<com.yonyou.cyxdms.basedata.service.vo.CarInfoVO>
     * @author renwd
     * @since 2019/6/25
     */
    @ApiOperation(value = "根据车系id或车型id或配置id或颜色id查询车的信息")
    @PostMapping("/selectCarInfo")
    public CarInfoVO selectCarInfo(@RequestBody CarInfoDTO carInfoDTO) {
        return colorService.selectCarInfoByCondition(carInfoDTO);
    }

    /**
     * 获取所有颜色
     *
     * @param colorType 16081002 外饰色,16081001内饰色
     * @return:
     * @auther: tanjie
     * @since: 2019/11/4
     */
    @GetMapping("/getAllColorByAppIdAndType")
    public List<ColorCacheVO> getAllColorByAppIdAndType(@RequestParam("appId") String appId, @RequestParam(
            value = "colorType", required = false) Integer colorType) {
        return this.colorService.getAllColorByAppIdAndType(appId, colorType);
    }
}
